Skip to content

fix(frcteamrank): handle null qual data from The Blue Alliance API#418

Merged
tavdog merged 2 commits intotronbyt:mainfrom
dragid10:fix/frc-team-rank-null-qual
Mar 20, 2026
Merged

fix(frcteamrank): handle null qual data from The Blue Alliance API#418
tavdog merged 2 commits intotronbyt:mainfrom
dragid10:fix/frc-team-rank-null-qual

Conversation

@dragid10
Copy link
Contributor

Summary

  • The Blue Alliance API returns "qual": null when an event is active but qualification matches haven't started yet
  • The existing null checks only verified key existence (not in), not whether the value was None, causing a crash on the in operator
  • Added == None checks at each nesting level in get_team_ranking() so the app gracefully falls back to the default ranking message

Also submitted to the upstream Tidbyt community repo: tidbyt/community#3196

The Blue Alliance returns "qual": null when an event is active but
matches haven't started yet. The existing checks only verified key
existence, not whether the value was None, causing a crash on the
`in` operator.
@dragid10 dragid10 requested a review from tavdog as a code owner March 20, 2026 17:02
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a robustness issue in the FRC Team Rank application by improving its handling of incomplete or null data returned by The Blue Alliance API. It ensures that the application can gracefully process event data even when qualification matches have not yet begun, preventing crashes and providing a consistent user experience.

Highlights

  • API Data Handling: The Blue Alliance API can return "qual": null when an event is active but qualification matches have not yet started, which previously caused a crash.
  • Null Check Improvement: Enhanced existing null checks to explicitly verify if a value is None, in addition to checking for key existence, preventing crashes when None values are encountered.
  • Graceful Fallback: Implemented == None checks at each nesting level within the get_team_ranking() function to ensure the application gracefully falls back to a default ranking message when data is unavailable.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a crash when The Blue Alliance API returns null for qualification data. The added checks for None values are appropriate. However, the implementation results in repetitive and deeply nested dictionary access, which impacts code readability and maintainability. A review comment has been added to suggest a refactoring that would simplify this logic.

Comment on lines 164 to 169
if "qual" not in ranking_data or ranking_data["qual"] == None:
return -1, 999
if "ranking" not in ranking_data["qual"]:
if "ranking" not in ranking_data["qual"] or ranking_data["qual"]["ranking"] == None:
return -1, 999
if "rank" not in ranking_data["qual"]["ranking"]:
if "rank" not in ranking_data["qual"]["ranking"] or ranking_data["qual"]["ranking"]["rank"] == None:
return -1, 999
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The repeated deep access into the ranking_data dictionary reduces readability and maintainability. Consider refactoring this block to use intermediate variables and the .get() method for safer and clearer access to nested data.

For example:

qual_data = ranking_data.get("qual")
if not qual_data:
    return -1, 999

ranking_info = qual_data.get("ranking")
if not ranking_info:
    return -1, 999

if ranking_info.get("rank") is None:
    return -1, 999

This approach simplifies data extraction and would make the subsequent assignments to team_ranking and total_teams cleaner and safer.

…ing data

Simplifies nested dict access for readability and safety.
@dragid10
Copy link
Contributor Author

Also I am the original creator of this app on Tidbyt 😃

@tavdog tavdog merged commit fe1da8a into tronbyt:main Mar 20, 2026
1 check passed
@dragid10 dragid10 deleted the fix/frc-team-rank-null-qual branch March 20, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants